<template>
	<view>
		<view class="list flex justify-center">
			<view class="list-box">
				<view class="list-box-item" v-for="(item,index) in list" :key="index">
					<view class="list-box-item-title" :style="item.type==1?'color:green;':'color:red;'">
						{{item.title}}
					</view>
					<view class="list-box-item-content">
						内容：{{item.content}}
					</view>
					<view class="list-box-item-time">
						时间：{{item.createTime}}
					</view>
					<view class="list-box-item-money add" v-if="item.type == 1">
						+{{item.money}}
					</view>
					<view class="list-box-item-money jian" v-else>
						-{{item.money}}
					</view>
				</view>
			</view>
		</view>
		<empty v-if="list.length==0"></empty>
	</view>
</template>

<script>
	import empty from '@/components/empty.vue'
	export default {
		components:{
			empty
		},
		data() {
			return {
				list:[],
				page:1,
				limit:10,
				pages:1
			};
		},
		onLoad() {
			this.getList()
		},
		onReachBottom() {
			if(this.pages > this.page){
				this.page += 1
				this.getList()
			}
		},
		methods:{
			getList(){
				let data = {
					page:this.page,
					limit:this.limit,
					// classify:4
				}
				this.$Request.getT('/app/userMoney/getBondDetails',data).then(res=>{
					if(res.code == 0){
						this.pages = res.data.pages
						if(this.page == 1){
							this.list = res.data.records
						}else{
							this.list = [...this.list,...res.data.records]
						}
					}else{
						this.list = []
					}
				})
			},
		},
	}
</script>

<style lang="scss">
	page {
		background-color: #F7F7F7;
	}
	.list{
		width: 100%;
		margin-top: 20rpx;
		.list-box{
			width: 686rpx;
			.list-box-item{
				width: 100%;
				border-radius: 16rpx;
				background-color: #ffffff;
				padding: 20rpx;
				margin-bottom: 20rpx;
			}
			.list-box-item-title{
				width: 100%;
				font-weight: bold;
				font-size: 30rpx;
				
			}
			.list-box-item-content{
				width: 100%;
				margin-top: 10rpx;
			}
			.list-box-item-time{
				width: 100%;
				margin-top: 10rpx;
				color: gray;
			}
			.list-box-item-money{
				width: 100%;
				text-align: end;
				font-weight: bold;
				font-size: 34rpx;
			}
			.add{
				color: green;
			}
			.jian{
				color: red;
			}
		}
	}
</style>